﻿@*@inherits RazorEngine.Templating.TemplateBase<Gardener.CodeGeneration.Dtos.CodeGenNameModel>*@

@using Gardener.Enums
@using Gardener.Client.Base.Constants
@@using Gardener.@(Model.ModuleUpper).Resources;

@@inherits @(Model.ModuleUpper)BaseEdit<@(Model.ClassName)Dto>

<Form Context="model"
      Loading="@@_isLoading"
      Model="@@_editModel"
      LabelCol="new ColLayoutParam { Span = 8 }"
      WrapperCol="new ColLayoutParam { Span = 16 }"
      OnFinish="OnFormFinish">
    @foreach (var item in Model.CodeGenConfigs)
    {
        @if (!item.IsEdit) continue;

        @switch (item.EditComponentType)
        {
            case ClientComponentType.Select:
            <FormItem Label="@@(localizer[@item.ColumnLocaleKeyRef])">
                <Select Mode="single"
                        DataSource="@@_select_@(item.NetColumnName)"
                        @@bind-Value="@@model.@item.NetColumnName"
                        ValueName="@@nameof(SelectItem.ValueName)"
                        LabelName="@@nameof(SelectItem.LabelName)"
                        TItem="SelectItem"
                        TItemValue="string"
                        EnableSearch
                        AllowClear>
                </Select>
            </FormItem>
            break;
            case ClientComponentType.DateTime:
            <FormItem Label="@@(localizer[@item.ColumnLocaleKeyRef])">
                <span>@@model.@item.NetColumnName</span>
                        @*.ToString(ClientConstant.DateTimeFormat)*@
            </FormItem>
            break;
            case ClientComponentType.Switch:
            <FormItem Label="@@(localizer[@item.ColumnLocaleKeyRef])">
                <Switch @@bind-Value="@@model.@item.NetColumnName"></Switch>
            </FormItem>
            break;
            default:
            <FormItem Label="@@(localizer[@item.ColumnLocaleKeyRef])">
                <Input @@bind-Value="@@model.@item.NetColumnName" />
            </FormItem>
            break;
        }
    }

    <FormItem WrapperColOffset="8" WrapperColSpan="16">
        <Space>
            @@if (!DrawerInputType.Select.Equals(this.Options.Type))
            {
                <SpaceItem>
                    <Button Type="@@ButtonType.Primary" HtmlType="submit">
                        @@localizer["Save"]
                    </Button>
                </SpaceItem>
            }
            <SpaceItem>
                <Button OnClick="_=>OnFormCancel()">
                    @@localizer["Cancel"]
                </Button>
            </SpaceItem>
        </Space>
    </FormItem>
</Form>